<template>
	<view class="container">
		<u-navbar back-icon-color="#FFFFFF" :background="{ background: 'linear-gradient(to right, #A36BFF 0%, #6D4BBE 100%)' }" :border-bottom="false" title="我的佣金" title-color="#FFFFFF"></u-navbar>
		<view class="wd-flex commission-head">
			<image class="backdrop" src="../../../static/icons/icon_commission.png" mode="aspectFit"></image>
			<image class="avatar" :src="userinfo.avatar" mode="aspectFill"></image>
			<view class="wd-flex-cell">
				<view class="name">{{userinfo.username}}<u-icon class="icon" name="woman" color="#FFFFFF" size="26"></u-icon></view>
				<view class="info">佣金总额:<text>{{userinfo.money}}</text>元</view>
			</view>
		</view>
		<view class="commission-list">
			<view class="commission-list__item" v-for="(item,index) in lists">
				<view class="commission-list__left">
					<view class="title">{{item.memo}}</view>
					<view class="time">{{item.createtime}}</view>
				</view>
				<view class="commission-list__right">
					<text class="plus">+￥{{item.money}}</text>
				</view>
			</view>
			<!-- <view class="commission-list__item">
				<view class="commission-list__left">
					<view class="title">推荐给某某瑜伽10次卡</view>
					<view class="time">2021-04-02 12:59</view>
				</view>
				<view class="commission-list__right">
					<text class="plus">+￥20.5</text>
				</view>
			</view> -->
			<!-- <view class="commission-list__item">
				<view class="commission-list__left">
					<view class="title">佣金提现至微信</view>
					<view class="time">2021-04-02 12:59</view>
				</view>
				<view class="commission-list__right">
					<text class="minus">-￥200</text>
				</view>
			</view> -->
		</view>
	</view>
</template>

<script>
	
	export default {
		data() {
			return {
				user_id: 0,
				userinfo:{},
				lists:[],
				current_page:1,
				last_page:1,
			}
		},
		onLoad(options){
			if(options.user_id){
				this.user_id = options.user_id;
				this.get_detail()
				this.get_lists();
			}
		},
		methods: {
			
			get_detail(){
				var that = this;
				var user_id = that.user_id;
				let postData = {
				    user_id: user_id
				};
				var option = {
					tip_status: false,
					method: 'POST',
					tips: 'loading',
					url: 'api/manage/user_detail',
					data: postData
				};
				//联网加载数据
				http.common_request(that,option,function(data){
					that.userinfo = data.data;
				})
			},
			
			get_lists(){
				var that = this;
				var user_id = that.user_id;
				let postData = {
					user_id: user_id
				};
				var option = {
					tip_status: false,
					method: 'POST',
					tips: 'loading',
					url: 'api/manage/commision_list',
					data: postData
				};
				//联网加载数据
				http.common_request(that,option,function(data){
					var lists = that.lists;
					for(var i=0;i<data.data.data.length;i++){
						lists.push(data.data.data[i]);
					}
					++data.data.current_page;
					that.lists = lists;
					that.current_page = data.data.current_page;
					that.last_page = data.data.last_page;
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.commission-head {
		position: relative;
		padding: 24rpx;
		padding-bottom: 48rpx;
		height: 200rpx;
		background: linear-gradient(to right, #A36BFF 0%, #6D4BBE 100%);
		overflow: hidden;
		.backdrop {
			position: absolute;
			top: 0;
			right: 0;
			display: block;
			width: 188rpx;
			height: 200rpx;
		}
		.avatar {
			display: block;
			margin-right: 40rpx;
			width: 98rpx;
			height: 98rpx;
			border-radius: 50%;
		}
		.name {
			line-height: 40rpx;
			font-size: 28rpx;
			font-weight: 500;
			color: #FFFFFF;
		}
		.icon {
			margin-left: 10rpx;
		}
		.info {
			line-height: 40rpx;
			font-size: 24rpx;
			color: #FFFFFF;
			text {
				padding: 0 10rpx;
				font-size: 34rpx;
				font-weight: 500;
			}
		}
	}
	.commission-list {
		position: relative;
		margin-top: -24rpx;
		padding: 0 24rpx;
		border-radius: 24rpx;
		background: #FFFFFF;
		&__item {
			display: flex;
			align-items: center;
			border-bottom: 1rpx #EDEDED solid;
			padding: 32rpx 0;
		}
		&__left {
			flex: 1;
			overflow: hidden;
			.title {
				line-height: 40rpx;
				font-size: 28rpx;
				color: #191919;
			}
			.time {
				margin-top: 8rpx;
				line-height: 34rpx;
				font-size: 24rpx;
				color: #999999;
			}
		}
		&__right {
			line-height: 40rpx;
			font-size: 28rpx;
			font-weight: 500;
			.plus {
				color: #F00000;
			}
			.minus {
				color: #00B620;
			}
		}
	}
</style>